import 'dart:async';
import 'dart:typed_data';
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_native_image/flutter_native_image.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:magic_car/UI/Loading.dart';
import 'package:magic_car/UI/chejia_board.dart';
import 'package:magic_car/UI/mykeyboard.dart' as board;
import 'package:magic_car/authinspcter/commonwidget/my_muti_selector.dart';
import 'package:magic_car/baoxiu/brandselect.dart';
import 'package:magic_car/baoxiu/cartype.dart';
import 'package:magic_car/bussiness/bussinessinspect.dart';
import 'package:magic_car/jiance/inspectstart.dart';
import 'package:magic_car/jiance/papularInspects.dart';
import 'package:magic_car/jiance/start.dart';
import 'package:magic_car/res/resources.dart';
import 'package:magic_car/user/chargerVip.dart';
import 'package:magic_car/util/colors.dart';
import 'package:magic_car/util/config.dart';
import 'package:magic_car/util/galleryphotoview.dart';
import 'package:magic_car/zhanshi/cheyuandetail.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:toast/toast.dart';
import 'package:flutter/material.dart';
import 'package:magic_car/util/HttpHelper.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
import 'package:date_format/date_format.dart';
//import 'package:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';
import 'package:flutter_cupertino_date_picker_fork/flutter_cupertino_date_picker_fork.dart';
import 'package:flutter/services.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

class BusinessAuthStartPage extends StatefulWidget {
  final int type; // 1 为检测师录车源 2 为车商录车源
  final String appoint_order_id; //检测订单id ,如果车商录车源时，填0
  final String bid; //车商id,当检测师录入车源时需要传入
  BusinessAuthStartPage(this.type, this.appoint_order_id, this.bid);

  // final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<BusinessAuthStartPage>
    with AutomaticKeepAliveClientMixin {
  bool get wantKeepAlive => true;
  String current_brand = "";
  String current_type = "";

  bool select = false;
  String pwdData = '输入车牌';

  bool showkb = false;
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

  // VoidCallback：没有参数并且不返回数据的回调
  VoidCallback _showBottomSheetCallback;

  String MIN_DATETIME = '1900-01-01';
  String MAX_DATETIME = '2025-01-01';
  String INIT_DATETIME = '2020-05-01';

  DateTimePickerLocale _locale = DateTimePickerLocale.zh_cn;
//DateTimePickerLocale _locale = Locale('zn');
  List<DateTimePickerLocale> _locales = DateTimePickerLocale.values;

  String _format = 'yyyy-MMMM';
  TextEditingController _formatCtrl = TextEditingController();

  DateTime _dateTime;
  // TextEditingController _nametroller = new TextEditingController();
  // TextEditingController _agetroller = new TextEditingController();
  // TextEditingController _mobiletroller = new TextEditingController();
  // TextEditingController _validtroller = new TextEditingController();
  // TextEditingController _idcardtroller = new TextEditingController();
  // TextEditingController _expricetroller = new TextEditingController();
  // TextEditingController _passtroller = new TextEditingController();
  // TextEditingController _confirmpasstroller = new TextEditingController();
  List formList;
  bool agreen = false;
  File _image;
  String card_z = '';
  String card_f = '';
  bool select_img = false;
  String status = "1";
  List imgs = new List();
  List thumb = [];
  String xsz_url = "";
  List img_url = new List();
  Map userInfo;
  bool ispay = true;
  bool isend = true;
  String days = "";
  TextEditingController car_num = new TextEditingController();
  TextEditingController car_price = new TextEditingController();
  TextEditingController guide_car_price = new TextEditingController();
  TextEditingController num_km = new TextEditingController();
  TextEditingController people = new TextEditingController();
  TextEditingController mobile = new TextEditingController();
  TextEditingController address = new TextEditingController();
  TextEditingController desrible = new TextEditingController();
  TextEditingController biaoxianlicheng = new TextEditingController();
  TextEditingController pailiang = new TextEditingController();
  TextEditingController guohucishu = new TextEditingController();
  TextEditingController paizhaodi = new TextEditingController();
  TextEditingController chejia = new TextEditingController();
  String fdj = "";
  int seconds = 720;

  bool canceltimes = false;

  String oid = "";

  String titleshow = "录入车源";

  Timer _countdownTimer; //自动保存的计时器
  List pfbzarr = [
    {"title": "国一", "select": true, "fanli": "0", "value": 1},
    {"title": "国二", "select": false, "fanli": "0", "value": 2},
    {"title": "国三", "select": false, "fanli": "0", "value": 2},
    {"title": "国四", "select": false, "fanli": "0", "value": 2},
    {"title": "国五", "select": false, "fanli": "0", "value": 2},
    {"title": "国六", "select": false, "fanli": "0", "value": 2},
    {"title": "国七", "select": false, "fanli": "0", "value": 2},
    {"title": "其他", "select": false, "fanli": "0", "value": 2},
    {"title": "未知", "select": false, "fanli": "0", "value": 2},
  ];
  List bsxarr = [
    {"title": "自动", "select": true, "fanli": "0", "value": 1},
    {"title": "手动", "select": false, "fanli": "0", "value": 0}
  ];
  initState() {
    super.initState();
    _showBottomSheetCallback = _showBottomSheet;
    formList = [
      {
        "title": '车牌号',
        'sub_title': '云A00001',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 6,
        'bottom': 1.0,
        'value': '',
        'code': '',
        'ctroller': car_num,
        'text_type': 1,
        'max_length': 0,
        'isedit': 0
      },
      {
        "title": '车架号',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 200,
        'bottom': 1.0,
        'value': '请输入车架号',
        'code': 'cj',
        'ctroller': chejia,
        'text_type': 2,
        'max_length': 17,
        'isedit': 0
      },
      {
        "title": '上牌时间',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 2,
        'bottom': 1.0,
        'value': '选择上牌时间',
        'code': 'sp_time',
        // 'ctroller':car_price,
        'text_type': 1,
        'isedit': 0,
        'max_length': 0
      },
      // {
      //   "title": '上牌日期',
      //   'sub_title': '云A00001',
      //   'sub_color': Color.fromRGBO(27, 182, 251, 1),
      //   'type': 2,
      //   'bottom': 1.0,
      //   'value': '请选择日期',
      //   'code': ''
      // },
      {
        "title": '车辆品牌',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 3,
        'bottom': 1.0,
        'value': '请选择品牌',
        'code': '',
        'brand_id': '',
        'isedit': 0
      },
      {
        "title": '车辆车系',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 3,
        'bottom': 1.0,
        'value': '请选择车型',
        'code': '',
        'type_id': '',
        'isedit': 0
      },
      {
        "title": '车辆车型',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 3,
        'bottom': 10.0,
        'value': '请选择款式',
        'code': '',
        'typelist_id': '0',
        'price': '0.00',
        'isedit': 0
      },

      {
        "title": '新车指导价(万)',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 10.0,
        'value': '0.00',
        'code': 'guide_price',
        'ctroller': guide_car_price,
        'text_type': 2,
        'max_length': 0,
        'isedit': 0
      },
      {
        "title": '当前车价(万)',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 10.0,
        'value': '0.00',
        'code': 'car_price',
        'ctroller': car_price,
        'text_type': 2,
        'max_length': 0,
        'isedit': 0
      },

      {
        "title": '里程(至个位)',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 1.0,
        'value': '',
        'code': 'bxlc',
        'ctroller': biaoxianlicheng,
        'text_type': 2,
        'max_length': 0,
        'isedit': 0
      },

      {
        "title": '排放标准',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 8,
        'bottom': 1.0,
        'value': '国一',
        'code': 'pfbz',
        'ctroller': car_price,
        'text_type': 1,
        'max_length': 0,
        'item': '国一,国二,国三,国四,国五,国六,国七,其他,未知',
        'isedit': 0,
      },
      {
        "title": '排量',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 1.0,
        'value': '',
        'code': 'pl',
        'ctroller': pailiang,
        'text_type': 2,
        'max_length': 0,
        'isedit': 0
      },
      {
        "title": '变速箱',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 8,
        'bottom': 1.0,
        'value': '自动',
        'code': 'bsx',
        // 'ctroller': car_price,
        'text_type': 1,
        'max_length': 0,
        'item': '手动,自动',
        'isedit': 0
      },
      {
        "title": '过户次数',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 1.0,
        'value': '',
        'code': 'ghcs',
        'ctroller': guohucishu,
        'text_type': 1,
        'max_length': 0,
        'isedit': 0
      },
      {
        "title": '所在城市',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 10.0,
        'value': '',
        'code': 'pzd',
        'ctroller': paizhaodi,
        'text_type': 2,
        'max_length': 0,
        'isedit': 0
      },
      // {
      //   "title": '上架时间',
      //   'sub_title': '云A00001云A00001云A00',
      //   'sub_color': Color.fromRGBO(27, 182, 251, 1),
      //   'type': 1,
      //   'bottom': 10.0,
      //   'value': '',
      //   'code': 'price',
      //   'ctroller': car_price,
      //   'text_type': 1,
      //   'max_length': 0
      // },

      {
        "title": '联系人',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 1.0,
        'value': '',
        'code': 'contact_people',
        'ctroller': people,
        'text_type': 2,
        'max_length': 5,
        'isedit': 0
      },
      {
        "title": '联系电话',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 1,
        'bottom': 1.0,
        'value': '',
        'code': 'contact_mobile',
        'ctroller': mobile,
        'text_type': 1,
        'max_length': 11,
        'isedit': 0
      },
      // {
      //   "title": '地址',
      //   'sub_title': '云A00001云A00001云A00',
      //   'sub_color': Color.fromRGBO(27, 182, 251, 1),
      //   'type': 1,
      //   'bottom': 10.0,
      //   'value': '',
      //   'code': 'address',
      //   'ctroller':address,
      //   'text_type':2
      // },
      // {
      //   "title": '车型',
      //   'sub_title': '云A00001云A00001云A00',
      //   'sub_color': Color.fromRGBO(27, 182, 251, 1),
      //   'type': 3,
      //   'bottom': 10.0,
      //   'value': '',
      //   'code': ''
      // },
      {
        "title": '车源封面图片',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 4,
        'bottom': 10.0,
        'value': '',
        'code': ''
      },
      {
        "title": '车源图片(外观/内饰)',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 4,
        'bottom': 10.0,
        'value': '',
        'code': ''
      },
      {
        "title": '车源简介',
        'sub_title': '云A00001云A00001云A00',
        'sub_color': Color.fromRGBO(27, 182, 251, 1),
        'type': 5,
        'bottom': 10.0,
        'value': '',
        'code': 'car_descrble',
        'ctroller': desrible,
        'isedit': 0
      },
    ];
    //imgs.add({'url':'''order["status"].toString() != "3"'''}'resource/images/user/upimg.png');
    imgs = [
      {'url': '', 'name': '前脸', 'isupdate': 0},
      // {'url': '', 'name': '左前45度', 'isupdate': 0},
      // {'url': '', 'name': '右后45度', 'isupdate': 0},
      // {'url': '', 'name': '侧面', 'isupdate': 0},
      // {'url': '', 'name': '前排', 'isupdate': 0},
      // {'url': '', 'name': '后排', 'isupdate': 0},
      // {'url': '', 'name': '仪表台', 'isupdate': 0},
      // {'url': '', 'name': '主驾驶', 'isupdate': 0},
      // {'url': '', 'name': '发动机舱', 'isupdate': 0},
      // {'url': '', 'name': '车尾', 'isupdate': 0},
      // {'url': '', 'name': '底盘', 'isupdate': 0},
      // {'url': '', 'name': '亮点配置', 'isupdate': 0},
    ];
    thumb = [
      {'url': '', 'name': '前脸', 'isupdate': 0},
    ];
    geteditorder();
    //starttimes();
    //loaduserinfo();
    // loaduserinfo();
  }

  void _showBottomSheet() {
    setState(() {
      showkb = true;
    });
    print('键盘出现');
    this.formList[0]['isedit'] = 1;
    setState(() {
      formList = this.formList;
    });
    if (pwdData == "输入车牌") {
      setState(() {});
    }
    // new NumberKeyboardActionSheet(name: "1111", controller: car_num);
    setState(() {
      // disable the button  // 禁用按钮
      _showBottomSheetCallback = null;
    });

    /*
      currentState：获取具有此全局键的树中的控件状态
      showBottomSheet：显示持久性的质感设计底部面板
      解释：联系上文，_scaffoldKey是Scaffold框架状态的唯一键，因此代码大意为，
           在Scaffold框架中显示持久性的质感设计底部面板
     */
    _scaffoldKey.currentState
        .showBottomSheet<void>((BuildContext context) {
          /// 将自定义的密码键盘作为其child   这里将回调函数传入
          return new board.MyKeyboard(_onKeyDown, pwdData);
        })
        .closed
        .whenComplete(() {
          if (mounted) {
            setState(() {
              // re-enable the button  // 重新启用按钮
              _showBottomSheetCallback = _showBottomSheet;
            });
          }
        });
  }

  /// 密码键盘的整体回调，根据不同的按钮事件来进行相应的逻辑实现
  void _onKeyDown(board.KeyEvent data) {
    print("删除前车牌：" + pwdData);
// 如果点击了删除按钮，则将密码进行修改
    if (data.isDelete()) {
      if (pwdData != "输入车牌") {
        if (pwdData.length > 0) {
          pwdData = pwdData.substring(0, pwdData.length - 1);
          setState(() {});
        }
      }
      if (pwdData.length == 0) {
        setState(() {
          pwdData = "输入车牌";
        });
      }
    }
// 点击了确定按钮时
    else if (data.isCommit()) {
      print("点击完成");
      setState(() {
        pwdData = pwdData;
        showkb = false; //键盘隐藏
      });
      saveResult(false);
      Navigator.of(context).pop();
//      if (pwdData.length != 7) {
////        Fluttertoast.showToast(msg: "密码不足6位，请重试", gravity: ToastGravity.CENTER);
//        return;
//      }
      // onAffirmButton();
    }
//点击了数字按钮时  将密码进行完整的拼接
    else {
      if (pwdData.length == 0) {}
      if (pwdData == "输入车牌") {
        setState(() {
          pwdData = "";
        });
      }
      if (pwdData.length < 7) {
        pwdData += data.key;
      }
      if (pwdData.length == 7 || pwdData.length > 7) {
        if (showkb == true) {
          Navigator.of(context).pop();
          setState(() {
            showkb = false;
          });
        }
      }
      setState(() {
        pwdData = pwdData;
      });
    }
    saveResult(false);
  }

  loaduserinfo() async {
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    SharedPreferences pref = await SharedPreferences.getInstance();
    // pref.remove("islogin");
    Map<String, String> map = new Map();
    map["id"] = pref.getString('uid');

    HttpHelper.post(HttpHelper.API_BusinessInfo, (data) async {
      //loadpage.close();
      if (data != null) {
        print(data);
        //Toast.show(data["msg"], context);

        if (data["code"].toString() == "1") {
          setState(() {
            userInfo = data["info"];
          });
          if (data['info']['is_bussiness'].toString() == "1") {
            setState(() {
              titleshow = "录入车源（车商）";
            });
          } else {
            setState(() {
              titleshow = "录入车源（经纪人）";
            });
          }
          if (data['info']['is_pay'].toString() == "0") {
            setState(() {
              ispay = false;
            });
            if (data['info']['free_end'].toString() == '1') {
              setState(() {
                isend = true;
              });
            } else {
              setState(() {
                isend = false;
                days = data['info']['free_end_day'].toString();
              });
            }
          } else {
            setState(() {
              ispay = true;
            });
          }

          var info = data["info"];
          setState(() {
            status = info["status"].toString();
            if (status == "1") {
              pref.setString("isshenhe", '1');
            }
          });
        }
      }
    }, params: map);
  }

  Widget layout() {
    List<Widget> tiles = [];
    Widget content;
    tiles.add(Align(
        alignment: Alignment.centerLeft,
        child: Padding(
            padding: new EdgeInsets.fromLTRB(10, 0, 0, 10),
            child: Text('填写基本信息(请规范填写各项信息)'))));
    //新车指导价100万内可下单
    tiles.add(Align(
        alignment: Alignment.centerLeft,
        child: Padding(
            padding: new EdgeInsets.fromLTRB(10, 0, 0, 10),
            child: Text(
              '* 新车指导价100万内可下单',
              style: TextStyle(color: Colors.red, fontWeight: FontWeight.w800),
            ))));
    Map tempitem = {
      "title": '行驶证识别',
      'sub_title': '云A00001',
      'sub_color': Color.fromRGBO(27, 182, 251, 1),
      'type': 1024,
      'bottom': 1.0,
      'value': '',
      'code': '',
      'text_type': 1,
      'max_length': 0,
      'isedit': 0
    };
    tiles.add(xingshiimg(tempitem));
    for (var item in formList) {
      var type = item["type"];
      if (type == 1) {
        //输入框
        tiles.add(inputWidget(item));
      } else if (type == 2) {
        //时间选择
        tiles.add(dateSelect(item));
      } else if (type == 3) {
        //类型选择
        tiles.add(cartype(item));
      } else if (type == 4) {
        //图片
        tiles.add(uploadImgs(item));
      } else if (type == 5) {
        if (widget.type == 1) {
          desrible.text = "暂无";
          item["value"] = "暂无";
        } else {
          tiles.add(textarea(item));
        }
      } else if (type == 200) {
        tiles.add(chejiainputWidget(item));
      } else if (type == 6) {
        tiles.add(carNuminput(item));
      } else if (type == 8) {
        if (item['code'] == 'pfbz') {
          tiles.add(pfbawidget());
        } else if (item["code"] == "bsx") {
          tiles.add(bsxwidget());
        }
        //  tiles.add(checkBoxs(item));
      }
    }
    // var btn = new SizedBox(
    //     width: double.infinity,
    //     height: 50,
    //     child: new FlatButton(
    //       child: Text('立即申请入驻'),
    //       textColor: Colors.white,
    //       color: Colors.white,
    //       //color: Color.fromRGBO(27, 182, 251, 1),
    //       onPressed: () {
    //         regist();
    //       },
    //     ));
    var btn = new Container(
        color: Color.fromRGBO(239, 239, 239, 1),
        //color:Colors.white,
        child: new Padding(
            padding: new EdgeInsets.fromLTRB(10, 0, 20, 0),
            child: new Material(
              color: Color.fromRGBO(239, 239, 239, 1),
              //INK可以实现装饰容器
              child: new Ink(
                //用ink圆角矩形
                //color: Color.fromRGBO(239, 239, 239, 1),
                decoration: new BoxDecoration(
                  //背景

                  color: Colours.app_main,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(18.0)),
                  //设置四周边框
                  border: new Border.all(width: 1, color: Colours.app_main),
                ),
                child: new InkWell(

                    //圆角设置,给水波纹也设置同样的圆角
                    //如果这里不设置就会出现矩形的水波纹效果
                    borderRadius: new BorderRadius.circular(15.0),
                    //设置点击事件回调
                    onTap: () {
                      showModalBottomSheet(
                          context: context,
                          builder: (BuildContext context) {
                            return Padding(
                                padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                                child: Container(
                                  height: 130,
                                  child: new Column(children: <Widget>[
                                    new Container(
                                        decoration: new BoxDecoration(
                                            border: Border(
                                                bottom: BorderSide(
                                                    width: 1,
                                                    color: Color(0xffe5e5e5)))),
                                        height: 50,
                                        child: Center(
                                            child: Text('是否确认提交车辆信息！',
                                                style:
                                                    TextStyle(fontSize: 16)))),
                                    new Container(
                                        decoration: new BoxDecoration(
                                            border: Border(
                                                bottom: BorderSide(
                                                    width: 1,
                                                    color: Color(0xffe5e5e5)))),
                                        height: 40,
                                        child: new GestureDetector(
                                            behavior: HitTestBehavior.opaque,
                                            onTap: () async {
                                              Navigator.pop(context);
                                              submit();
                                            },
                                            child: Center(
                                                child: Text('确认',
                                                    style: TextStyle(
                                                        fontSize: 16,
                                                        color: Colors.red))))),
                                    new Container(
                                        height: 40,
                                        child: new GestureDetector(
                                            behavior: HitTestBehavior.opaque,
                                            onTap: () {
                                              Navigator.pop(context);
                                            },
                                            child: Center(
                                                child: Text('取消',
                                                    style: TextStyle(
                                                        fontSize: 16))))),
                                  ]),
                                ));
                          });
                    },
                    child: Container(
                      //设置 child 居中
                      alignment: Alignment(0, 0),
                      height: 36,
                      //color: Color.fromRGBO(239, 239, 239, 1),
                      width: double.infinity,
                      child: Text(
                        "下一步",
                        style: TextStyle(color: Colors.white),
                      ),
                    )),
              ),
            )));
    tiles.add(btn);
    content = new Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, 10),
        child: new Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
            //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
            ));
    return content;
  }

  //上传行驶证
  //选择图片
  getxszimgs(type, index) async {
    var image;
    if (type == 1) {
      image = await ImagePicker.pickImage(source: ImageSource.gallery);
    } else {
      image = await ImagePicker.pickImage(source: ImageSource.camera);
    }
    if (image == null) return;
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    // File _files = await FlutterNativeImage.compressImage(image.path);
    File _files = image;

    Map<String, String> map = new Map();
    Map imgitem;

    HttpHelper.upLoadImageNocompress(_files, (data) {
      //loadpage.close();
      print('data');
      if (data.containsKey('code')) {
        Toast.show(data['msg'], context);
      } else {
        // imgitem = {
        //   'isupdate': 1,
        //   'url': data["url"],
        //   'attachment': data["attachment"]
        // };
        // if (index == 0)
        //   imgs.add(imgitem);
        // else
        //   thumb.add(imgitem);

        // setState(() {
        //   imgs = imgs;
        //   thumb = thumb;
        // });

        // saveResult(false);

        scanxsz(data["url"]);
        //  setState(() {
        //   xsz_url = data["url"];
        // });
      }
    }, params: map);
  }

  //识别行驶证
  scanxsz(url) {
    Toast.show('信息识别中...', context);
    Map<String, String> param = new Map();

    param['img'] = url;
    HttpHelper.post(HttpHelper.API_Scanxsz, (data) async {
      //loadpage.close();
      //loadpage.close();
      if (data != null) {
        setState(() {
          xsz_url = url;
        });
        print(data);
        Map response1 = data['Response'];
        if (response1.containsKey('FrontInfo')) {
          if (response1['FrontInfo'].containsKey('PlateNo')) {
            setState(() {
              pwdData = response1['FrontInfo']['PlateNo'];
            });
          }
          if (response1['FrontInfo'].containsKey('Vin')) {
            setState(() {
              chejia.text = response1['FrontInfo']['Vin'];
            });
            for (var item in formList) {
              if (item['title'] == "车架号") {
                item['value'] = response1['FrontInfo']['Vin'];
              }
            }
          }
          if (response1['FrontInfo'].containsKey('RegisterDate')) {
            for (var item in formList) {
              if (item['title'] == "上牌时间") {
                item['value'] = response1['FrontInfo']['RegisterDate'];
              }
            }
          }
          if (response1['FrontInfo'].containsKey('EngineNo')) {
            //发动机号EngineNo
            fdj = response1['FrontInfo']['EngineNo'];
          }
          setState(() {
            formList = formList;
          });
          saveResult(false);
        } else {
          Toast.show("没有识别到相关信息", context);
        }
      }
    }, params: param);
  }

  //行驶证上传
  Widget xingshiimg(item) {
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
          color: Colors.white,
          width: double.infinity,
          // height: 160,
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              new Padding(
                padding: new EdgeInsets.fromLTRB(10, 10, 10, 0),
                child: RichText(
                  text: TextSpan(
                      text: item["title"],
                      style: TextStyle(
                          fontSize: 15,
                          color: Color.fromRGBO(102, 102, 102, 1)),
                      children: [
                        // TextSpan(
                        //     text: '*',
                        //     style: TextStyle(fontSize: 14, color: Colors.red))
                      ]),
                ),
              ),
              Padding(
                  padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                  child: Container(
                      color: Colors.white,
                      // height: 100,
                      child: new Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: <Widget>[
                            InkWell(
                                onTap: () {
                                  //选择图片
                                  showDialog(
                                      context: context,
                                      builder: (BuildContext context) {
                                        return new SimpleDialog(
                                          title: new Text('选择'),
                                          children: <Widget>[
                                            new SimpleDialogOption(
                                              child: new Text('相机'),
                                              onPressed: () {
                                                Navigator.pop(context);
                                                getxszimgs(0, 1);
                                              },
                                            ),
                                            new SimpleDialogOption(
                                              child: new Text('相册'),
                                              onPressed: () {
                                                Navigator.pop(context);
                                                getxszimgs(1, 1);
                                              },
                                            )
                                          ],
                                        );
                                      });
                                },
                                child: Center(
                                  child: xsz_url == ""
                                      ? Image.asset(
                                          'resource/images/user/xsz.png',
                                          width: 150,
                                          height: 150,
                                          fit: BoxFit.fitHeight)
                                      : CachedNetworkImage(
                                          imageUrl: xsz_url,
                                          width: MediaQuery.of(context)
                                                  .size
                                                  .width -
                                              30,
                                          // height: 150,
                                          fit: BoxFit.fitWidth),
                                ))
                            // new Container(child: buildCImgs(item["title"]=="车源封面图片"?thumb:imgs))
                          ]))),

              //  Expanded(
              //   child:
            ],
          ),
        ));
    return content;
  }

  _saveImg(avatar) async {
    if (Platform.isAndroid) {
      if (await Permission.storage.request().isGranted) {
        var response = await Dio()
            .get(avatar, options: Options(responseType: ResponseType.bytes));
        // final result =
        // await ImageGallerySaver.saveFile(Uint8List.fromList(response.data));
        final result = await ImageGallerySaver.saveImage(
            Uint8List.fromList(response.data));
        print('result:$result');
      }
    } else {
      if (await Permission.photos.request().isGranted) {
        var response = await Dio()
            .get(avatar, options: Options(responseType: ResponseType.bytes));
        // final result =
        // await ImageGallerySaver.saveFile(Uint8List.fromList(response.data));
        final result = await ImageGallerySaver.saveImage(
            Uint8List.fromList(response.data));
        print('result:$result');
      }
    }
  }
  //车牌键盘布局

  Widget carNuminput(item) {
    DateTime initialDate = DateTime.now();
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
            color: Colors.white,
            height: 50,
            child: new GestureDetector(
              behavior: HitTestBehavior.opaque,
              onTap: () {
                FocusScope.of(context).requestFocus(FocusNode());
                _showBottomSheetCallback();
              },
              child: new Row(
                children: <Widget>[
                  Expanded(
                    child: new Padding(
                      padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                      child: RichText(
                        text: TextSpan(
                            text: item["title"],
                            style:
                                TextStyle(fontSize: 15, color: Colours.text_gray
                                    //color: Color.fromRGBO(102, 102, 102, 1)
                                    ),
                            children: [
                              // TextSpan(
                              //     text: '*',
                              //     style: TextStyle(fontSize: 14, color: Colors.red))
                            ]),
                      ),
                    ),
                    flex: 1,
                  ),
                  Expanded(
                    child: Padding(
                        padding: new EdgeInsets.fromLTRB(10, 0, 30, 0),
                        child:
                            // new GestureDetector(
                            //   onTap: (){
                            //     _showBottomSheetCallback();
                            //   },
                            //   child:
                            Align(
                          alignment: Alignment.centerRight,
                          child:
                              // new GestureDetector(
                              //     child:
                              new Text(pwdData),
                        )),
                    flex: 2,
                  )
                ],
              ),
            )));
    return content;
  }

//变速箱选择的组件
  Widget bsxwidget() {
    return Container(
        width: MediaQuery.of(context).size.width - 20,
        padding: new EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.0),
        ),
        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          Container(
            child: Text(
              "变速箱",
              style: TextStyle(fontSize: 15, color: Colours.text_gray
                  // color: Color.fromRGBO(102, 102, 102, 1)
                  ),
            ),
          ),
          Gaps.vGap10,
          Container(
              child:
                  Wrap(spacing: 2, runSpacing: 10, children: menuitem(bsxarr))),
        ]));
  }

  //排放标准的组件
  Widget pfbawidget() {
    return Container(
        width: MediaQuery.of(context).size.width - 20,
        padding: new EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.0),
        ),
        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          Container(
            child: Text(
              "排放标准",
              style: TextStyle(fontSize: 15, color: Colours.text_gray
                  // color: Color.fromRGBO(102, 102, 102, 1)
                  ),
            ),
          ),
          Gaps.vGap10,
          Container(
              child: Wrap(
                  spacing: 2, runSpacing: 10, children: menuitem(pfbzarr))),
        ]));
  }

  List<Widget> menuitem(data) {
    print(data);
    List<Widget> tiles = [];
    for (int i = 0; i < data.length; i++) {
      tiles.add(Container(
        padding: EdgeInsets.only(left: 1, top: 5, right: 10, bottom: 5),
        child: ChoiceChipWidget(
          // padding: new EdgeInsets.all(10),
          boxSelectColor: Colours.app_main,
          textSelectColor: Colors.white,
          selectBorder: Border.fromBorderSide(BorderSide(
              color: Colours.app_main, width: 1, style: BorderStyle.solid)),
          boxColor: Colours.base_gray,
          textColor: Colours.text_gray,
          // selectBorder: bod,
          height: 34,

          text: data[i]["title"],
          fontSize: 12,
          selected: data[i]["select"],
          border: Border.fromBorderSide(BorderSide(
              color: Colours.base_page_color,
              width: 1,
              style: BorderStyle.solid)),

          onSelected: (selected) {
            int selectnum = 0;
            for (int k = 0; k < data.length; k++) {
              if (k != i) {
                data[k]["select"] = false;
              }
              // if (taocan_arr[i]["select"] == true) selectnum++;
            }
            // if (selectnum > 2 && data[i]["select"] == false) {
            //   Toast.show("最多选择三个");
            //   return;
            // }
            data[i]["select"] = !data[i]["select"];
            if (data[i]["select"]) {
              //选中的时候进行数据处理

            }
            if (data == pfbzarr) {
              setState(() {
                pfbzarr = pfbzarr;
                // formList[9]['value'] = data[i]['title'];
              });
              for (var item in formList) {
                if (item['title'] == "排放标准") {
                  item['value'] = data[i]['title'];
                }
              }
            } else if (data == bsxarr) {
              setState(() {
                bsxarr = bsxarr;
                // formList[11]['value'] = data[i]['title'];
              });
              for (var item in formList) {
                if (item['title'] == "变速箱") {
                  item['value'] = data[i]['title'];
                }
              }
            }

            setState(() {
              formList = formList;
            });

            saveResult(false);
            // if(data==taocan_arr){
            // setState(() {
            //   taocan_arr = taocan_arr;
            //   dianzibool = i+1;
            //   // currntProduct = data[i];
            // });
            // }else {
            //   setState(() {
            //     expresstype = data;
            //     expresstypeindex = i+1;
            //   });
            // }
          },
        ),
      ));
    }
    return tiles;
  }

  // List<Widget> menuitem(data) {
  //   print(data);
  //   List<Widget> tiles = [];
  //   for (int i = 0; i < data.length; i++) {
  //     tiles.add(Container(
  //       padding: EdgeInsets.only(left: 1, top: 5, right: 10, bottom: 5),
  //       child: ChoiceChipWidget(
  //         boxSelectColor: Colours.app_main,
  //         textSelectColor: Colors.white,
  //         selectBorder: Border.fromBorderSide(BorderSide(
  //             color: Colours.app_main, width: 1, style: BorderStyle.solid)),
  //         boxColor: Colours.base_gray,
  //         textColor: Colours.text_gray,
  //         // selectBorder: bod,
  //         height: 34,

  //         text: data[i]["title"],
  //         fontSize: 12,
  //         selected: data[i]["select"],
  //         border: Border.fromBorderSide(BorderSide(
  //             color: Colours.base_page_color,
  //             width: 1,
  //             style: BorderStyle.solid)),

  //         onSelected: (selected) {
  //           int selectnum = 0;
  //           for (int k = 0; k < data.length; k++) {
  //             if (k != i) {
  //               data[k]["select"] = false;
  //             }
  //             // if (taocan_arr[i]["select"] == true) selectnum++;
  //           }
  //           // if (selectnum > 2 && data[i]["select"] == false) {
  //           //   Toast.show("最多选择三个");
  //           //   return;
  //           // }
  //           data[i]["select"] = !data[i]["select"];
  //           if (data[i]["select"]) {
  //             //选中的时候进行数据处理

  //           }
  //           if (data == pfbzarr) {
  //             setState(() {
  //               pfbzarr = pfbzarr;
  //               formList[9]['value'] = data[i]['title'];
  //             });
  //           } else if (data == bsxarr) {
  //             setState(() {
  //               bsxarr = bsxarr;
  //               formList[11]['value'] = data[i]['title'];
  //             });
  //           }
  //           saveResult(false);
  //           // if(data==taocan_arr){
  //           // setState(() {
  //           //   taocan_arr = taocan_arr;
  //           //   dianzibool = i+1;
  //           //   // currntProduct = data[i];
  //           // });
  //           // }else {
  //           //   setState(() {
  //           //     expresstype = data;
  //           //     expresstypeindex = i+1;
  //           //   });
  //           // }
  //         },
  //       ),
  //     ));
  //   }
  //   return tiles;
  // }

  Widget checkBoxs(item) {
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: new Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                  color: Colors.white,
                  height: 50,
                  child: new Row(children: <Widget>[
                    Expanded(
                      child: new Padding(
                        padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                        child: RichText(
                          text: TextSpan(
                              text: item["title"],
                              style: TextStyle(
                                  fontSize: 15,
                                  color: Color.fromRGBO(102, 102, 102, 1)),
                              children: [
                                // TextSpan(
                                //     text: '*',
                                //     style: TextStyle(fontSize: 14, color: Colors.red))
                              ]),
                        ),
                      ),
                      flex: 1,
                    ),
                    Expanded(
                      child: new Padding(
                          padding: new EdgeInsets.fromLTRB(10, 0, 20, 0),
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: RichText(
                              text: TextSpan(
                                  text: item["value"],
                                  style: TextStyle(
                                      fontSize: 15,
                                      color: Color.fromRGBO(102, 102, 102, 1)),
                                  children: [
                                    // TextSpan(
                                    //     text: '*',
                                    //     style: TextStyle(fontSize: 14, color: Colors.red))
                                  ]),
                            ),
                          )),
                      flex: 1,
                    ),
                  ])),
              checkBox(item)
            ]));
    return content;
  }

  Widget checkBox(item) {
    List<Widget> tiles = [];
    Widget content;
    print(item);

    List<String> items = item["item"].split(',');
    print('----');

    String defaultv = items[0];
    // if(this.type==2){
    if (select == false) {
      if (item.containsKey("value") == false) {
        item['value'] = defaultv;
      }
    }
    //}//车商设置选项默认值
    for (var i = 0; i < items.length; i++) {
      tiles.add(Container(
          child: Wrap(children: <Widget>[
        Padding(
            padding: new EdgeInsets.fromLTRB(10, 0, 0, 0),
            child: SizedBox(
                width: 22,
                child: Radio<String>(
                    materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                    //��前Radio的值
                    hoverColor: Color.fromRGBO(200, 200, 200, 1),
                    focusColor: Color.fromRGBO(25, 172, 249, 1),
                    value: items[i],
                    activeColor: Color.fromRGBO(25, 172, 249, 1),
                    groupValue: item['value'],
                    // groupValue: defaultv,
                    onChanged: (value) {
                      if (i != 0 && item['post_id'] != '3000') {
                        setState(() {
                          select = true;
                          // defaultv = value;
                          item['temp_mustimg'] = '1';
                        });
                      } else {
                        setState(() {
                          item['temp_mustimg'] = '0';
                        });
                      }
                      setState(() {
                        select = true;
                        // defaultv = value;
                        item['value'] = value;
                        item["isedit"] = 1;
                      });
                      saveResult(false);
                    }))),

        // tiles.add(
        new GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () {
              if (i != 0) {
                setState(() {
                  select = true;
                  // defaultv = value;
                  //item['mustimg'] = '1';
                  item['temp_mustimg'] = '1';
                });
              } else {
                setState(() {
                  item['temp_mustimg'] = '0';
                });
              }
              setState(() {
                item["value"] = items[i];
                item["isedit"] = 1;
              });
              saveResult(false);
            },
            child: Padding(
                padding: new EdgeInsets.fromLTRB(8, 12, 15, 0),
                child: Text(items[i],
                    style: new TextStyle(
                        fontSize: 11,
                        color: Color.fromRGBO(100, 100, 100, 1)))))
      ])));
    }
    content = new Wrap(spacing: 0, runSpacing: 0, children: tiles);
    //content = new Row(children: tiles);

    return content;
  }

  // //启动定时器
  // starttimes() {
  //   const period = const Duration(seconds: 5);

  //   _countdownTimer = Timer.periodic(period, (timer) {
  //     seconds--;
  //     if (seconds == 0) {
  //       _countdownTimer.cancel(); //一小时后结束时间计时
  //     }

  //     //到时回调
  //     if (!canceltimes) saveResult();
  //   });
  // }

  //获取草稿内容
  geteditorder() async {
    var caches = SpUtil.getObject("caches");
    print("缓存信息${caches}");
    if (caches == null) return;
    if (caches != null) {
      for (var item in formList) {
        if (item['code'] != "") {
          var code = item['code'];
          item["value"] = caches[code];
        }

        if (item['title'] == "车辆品牌") {
          item['value'] = caches['brand_name'];
          item['brand_id'] = caches['brand_id'];
        }
        if (item['title'] == "车辆车系") {
          item['value'] = caches['cartype_name'];
          item['type_id'] = caches['cartype_id'];
        }

        if (item['title'] == "车辆车型") {
          item['value'] = caches['type_list_name'];
          item['type_list_id'] = caches['type_list_id'];
        }

        if (item['title'] == '排放标准') {
          //  str = orderinfo["type_list_name"];
          item['value'] = caches["pfbz"];
          for (var pfbzitem in pfbzarr) {
            if (pfbzitem['title'] == caches["pfbz"]) {
              pfbzitem['select'] = true;
            } else {
              pfbzitem['select'] = false;
            }
          }
        }

        if (item['title'] == '变速箱') {
          //  str = orderinfo["type_list_name"];
          item['value'] = caches["bsx"];
          for (var pfbzitem in bsxarr) {
            if (pfbzitem['title'] == caches["bsx"]) {
              pfbzitem['select'] = true;
            } else {
              pfbzitem['select'] = false;
            }
          }
        }
      }
    }

    if (caches.containsKey("thumb_img")) {
      var thumbimgitem = {
        'isupdate': 1,
        'url': caches['thumb_img'],
        'attachment': caches["attachment"]
      };
      thumb.add(thumbimgitem);
      setState(() {
        thumb = thumb;
      });
    }
    if (caches['imgs'].toString().isNotEmpty) {
      List temp = caches['imgs'].toString().split(",");
      for (var item in temp) {
        if (item.toString().isNotEmpty) {
          var imgitem = {
            'isupdate': 1,
            'url': "http://img.chemogu1688.com/${item}",
            // 'url': "${HttpHelper.host}/attachment/${item}",
            'attachment': item
          };
          imgs.add(imgitem);
        }
      }
      setState(() {
        imgs = imgs;
      });
    }

    setState(() {
      formList = formList;

      pwdData = caches["car_num"];
      car_price.text = caches["car_price"];
      guide_car_price.text = caches["guide_price"];
      people.text = caches['contact_people'];
      mobile.text = caches['contact_mobile'];
      desrible.text = caches['car_descrble'];
      biaoxianlicheng.text = caches['bxlc'];
      guohucishu.text = caches['ghcs'];
      pailiang.text = caches['pl'];
      paizhaodi.text = caches['pzd'];
      chejia.text = caches["cj"];
    });
    // Map<String, String> param = new Map();

    // SharedPreferences pref = await SharedPreferences.getInstance();

    // param["bid"] = pref.getString('uid').toString();

    // print(param);

    // HttpHelper.post(HttpHelper.API_OrderCaogao, (data) async {
    //   if (data != null) {
    //     if (data["code"].toString() == "1") {
    //       List oldlist = formList;
    //       var orderinfo = data["info"];
    //       setState(() {
    //         oid = orderinfo['id'];
    //       });
    //       for (var i = 0; i < oldlist.length; i++) {
    //         print('111');
    //         var item = oldlist[i];
    //         var str = "";
    //         if (i == 0) {
    //           str = orderinfo["car_num"];
    //         } else if (i == 1) {
    //           //if(orderinfo["brand_string"].containsKey('name'))
    //           if (orderinfo['brand_id'].toString() != '0') {
    //             str = orderinfo["brand_string"]['name'];
    //             item['brand_id'] = orderinfo["brand_string"]['id'];
    //           }
    //         } else if (i == 2) {
    //           //if(orderinfo["cartype_string"].containsKey('name')){
    //           if (orderinfo['cartype_id'].toString() != '0') {
    //             str = orderinfo["cartype_string"]['name'];
    //             item['type_id'] = orderinfo["cartype_string"]['id'];
    //           }
    //         } else if (i == 3) {
    //           str = orderinfo["type_list_name"];
    //           item['typelist_id'] = orderinfo["type_list_id"];
    //         }
    //         // } else if (i == 4) {
    //         //   str = orderinfo["contact_people"];
    //         // } else if (i == 5) {
    //         //   str = orderinfo["contact_mobile"];
    //         // } else if (i == 7) {
    //         //   str = orderinfo["car_descrble"];
    //         // }

    //         if (item['code'] != "") {
    //           var code = item['code'];
    //           str = orderinfo[code];
    //           if (str == "") {
    //             if (code == "sp_time") {
    //               str = "请选择时间";
    //             }
    //           }
    //         }

    //         item["value"] = str;
    //       }

    //       print(oldlist);
    //       List tempImags = this.imgs;

    //       for (var i = 0; i < tempImags.length; i++) {
    //         var url = orderinfo['car_thumb'][i];
    //         if (url != '') {
    //           tempImags[i]['url'] = orderinfo['car_thumb'][i];
    //           List temparrStr = orderinfo['car_thumb'][i].split('attachment');
    //           print(temparrStr);
    //           //print(orderinfo['car_thumb'][i].split('attachment'));
    //           tempImags[i]['attachment'] =
    //               temparrStr[1].substring(1, temparrStr[1].length);
    //           tempImags[i]['isupdate'] = 1;
    //         }
    //       }

    //       setState(() {
    //         formList = oldlist;
    //         imgs = tempImags;
    //         pwdData = orderinfo["car_num"];
    //         car_price.text = orderinfo["car_price"];
    //         people.text = orderinfo['contact_people'];
    //         mobile.text = orderinfo['contact_mobile'];
    //         desrible.text = orderinfo['car_descrble'];
    //         biaoxianlicheng.text = orderinfo['bxlc'];
    //         guohucishu.text = orderinfo['ghcs'];
    //         pailiang.text = orderinfo['pl'];
    //         paizhaodi.text = orderinfo['pzd'];
    //         chejia.text = orderinfo["chejia_num"];
    //         // isyishou = orderinfo['yishou']=='1'?true:false;
    //         // isonline = orderinfo['is_online']=="1"?true:false;

    //         // orders=data["info"];
    //       });
    //       //pref.setStringList('userinfo', data["info"]);

    //     }
    //   }
    // }, params: param);
  }

  //通过车牌进行车源搜索
  getcarbyplatnum() async {
    Map<String, String> param = new Map();

    SharedPreferences pref = await SharedPreferences.getInstance();

    param["car_num"] = pwdData;

    print(param);

    HttpHelper.post(HttpHelper.API_CarByPlatnum, (data) async {
      if (data != null) {
        if (data["code"].toString() == "1") {
          List oldlist = formList;
          var orderinfo = data["info"];
          setState(() {
            oid = orderinfo['id'];
          });
          for (var i = 0; i < oldlist.length; i++) {
            print('111');
            var item = oldlist[i];
            var str = "";
            if (i == 0) {
              str = orderinfo["car_num"];
            }

            if (item['title'] == "车辆品牌") {
              if (orderinfo['brand_id'].toString() != '0') {
                str = orderinfo["brand_string"]['name'];
                item['brand_id'] = orderinfo["brand_string"]['id'];
              }
            }
            if (item['title'] == '车辆车系') {
              if (orderinfo['cartype_id'].toString() != '0') {
                str = orderinfo["cartype_string"]['name'];
                item['type_id'] = orderinfo["cartype_string"]['id'];
              }
            }
            if (item['title'] == '车辆车型') {
              str = orderinfo["type_list_name"];
              item['typelist_id'] = orderinfo["type_list_id"];
            }

            if (item['title'] == '排放标准') {
              //  str = orderinfo["type_list_name"];
              item['value'] = orderinfo["pfbz"];
              for (var pfbzitem in pfbzarr) {
                if (pfbzitem['title'] == orderinfo["pfbz"]) {
                  pfbzitem['select'] = true;
                } else {
                  pfbzitem['select'] = false;
                }
              }
            }

            if (item['title'] == '变速箱') {
              //  str = orderinfo["type_list_name"];
              item['value'] = orderinfo["bsx"];
              for (var pfbzitem in bsxarr) {
                if (pfbzitem['title'] == orderinfo["bsx"]) {
                  pfbzitem['select'] = true;
                } else {
                  pfbzitem['select'] = false;
                }
              }
            }

            if (item['code'] != "") {
              var code = item['code'];
              str = orderinfo[code];
              if (code == "cj") {
                str = orderinfo['chejia_num'];
              }
              if (str == "") {
                if (code == "sp_time") {
                  str = "请选择时间";
                }
              }
            }

            item["value"] = str;
          }

          print(oldlist);
          List tempImags = this.imgs;

          for (var i = 0; i < orderinfo['car_thumb'].length; i++) {
            var url = orderinfo['car_thumb'][i];
            if (url != '') {
              Map imageitems = {
                'attachment': orderinfo['car_thumb'][i],
                'url': orderinfo['car_thumb'][i],
                'isupdate': 1
              };
              imgs.add(imageitems);
            }
          }
          if (orderinfo['thumb'] != "") {
            Map imgitem = {
              'isupdate': 1,
              'url': orderinfo['thumb'],
              'attachment': ""
            };
            thumb.add(imgitem);
          }

          setState(() {
            formList = oldlist;
            pfbzarr = pfbzarr;
            bsxarr = bsxarr;
            imgs = tempImags;
            pwdData = orderinfo["car_num"];
            car_price.text = orderinfo["car_price"];
            people.text = orderinfo['contact_people'];
            mobile.text = orderinfo['contact_mobile'];
            desrible.text = orderinfo['car_descrble'];
            biaoxianlicheng.text = orderinfo['bxlc'];
            guohucishu.text = orderinfo['ghcs'];
            pailiang.text = orderinfo['pl'];
            paizhaodi.text = orderinfo['pzd'];
            chejia.text = orderinfo["chejia_num"];
            guide_car_price.text = orderinfo['guide_price'];
            thumb = thumb;
            imgs = imgs;
          });
          //pref.setStringList('userinfo', data["info"]);

        }
      }
    }, params: param);
  }

  saveResult(showalert) async {
    //  if (ispay == false && isend == true) {
    //   Toast.show('免费试用期已到，请先充值', context);
    //   return;
    // }
    Map<String, String> param = new Map();
    int empty = 0;
    for (var i = 0; i < this.formList.length; i++) {
      var item = this.formList[i];
      if (item['isedit'] == 1) empty++;
      if (item["code"] != "") {
        var code = item["code"];
        param[code] = item["value"].toString();
      }

      if (item['title'] == "车辆品牌") {
        param["brand_id"] = item['brand_id'];
        param['brand_name'] = item["value"];
      }

      if (item['title'] == "车辆车系") {
        param["cartype_id"] = item['type_id'];
        param["cartype_name"] = item["value"];
      }
      if (item['title'] == "车辆车型") {
        param["type_list_id"] = item['typelist_id'];
        param["type_list_name"] = item['value'];
      }
    }
    // if (empty == 0) return; //如果没有填过任何信息，不保存
    String image_Str = '';
    int isupdate = 0;
    for (var i = 0; i < imgs.length; i++) {
      var item = imgs[i];
      print(item);
      if (item['isupdate'] == 1) {
        isupdate++;
      }

      var tempStr = "";
      if (item.containsKey('attachment')) {
        tempStr = item['attachment'];
      }
      if (i == imgs.length - 1) {
        image_Str = image_Str + tempStr;
      } else
        image_Str = image_Str + tempStr + ',';
    }
    // if (isupdate == 0) {
    //   //请上传图片
    //   Toast.show('请上传图片', context);
    //   return;
    // }
    param["thumb"] = image_Str;
    // param["brand_id"] = formList[1]["brand_id"];
    // param['brand_name'] = formList[1]["value"];
    // param["cartype_id"] = formList[2]['type_id'];
    // param["cartype_name"] = formList[2]['value'];
    // param["type_list_id"] = formList[3]['typelist_id'];
    // param["type_list_name"] = formList[3]['value'];

    param["car_num"] = pwdData;
    param['imgs'] = image_Str;
    if (thumb.length > 1) {
      param['thumb_img'] = thumb[1]['url'];
    }

    SpUtil.putObject("caches", param);
    var caches = SpUtil.getObject("caches");
    print("缓存信息${caches}");
    // param["price"]=formList[1]["value"].toString();
    // param["contact_people"]=formList[2]["value"].toString();
    // param["contact_mobile"]=formList[3]["value"].toString();
    // param["address"]=formList[4]["value"].toString();
    // param["car_descrble"]=formList[6]["value"].toString();

    SharedPreferences pref = await SharedPreferences.getInstance();

    param["bid"] = pref.getString('uid').toString();
    param['isedit'] = '1'; //存为草稿内容

    // HttpHelper.post(HttpHelper.API_BussinessSuborder, (data) async {
    //   if (data != null) {
    //     if (data['code'].toString() == "1") {
    //       setState(() {
    //         oid = data["info"].toString();
    //       });
    //       if (showalert) Toast.show("信息保存成功", context);
    //     }
    //     print('保存草稿');
    //     print(data);
    //   }
    // }, params: param);
  }

//提交生成检测订单
  submit() async {
    FocusScope.of(context).requestFocus(FocusNode());
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    // if (ispay == false && isend == true) {
    //   Toast.show('免费试用期已到，请先充值', context);
    //   return;
    // }
    Map<String, String> param = new Map();
    for (var i = 0; i < this.formList.length; i++) {
      var item = this.formList[i];
      if (item["code"] != "") {
        var code = item["code"];
        if (item["value"] == "") {
          Toast.show('请填写完整的信息', context);
          return;
          // break;
        }
        param[code] = item["value"].toString();
      }

      if (item['title'] == "车辆品牌") {
        param["brand_id"] = item['brand_id'];
      }

      if (item['title'] == "车辆车系") {
        param["cartype_id"] = item['type_id'];
      }
      if (item['title'] == "车辆车型") {
        param["type_list_id"] = item['typelist_id'];
        param["type_list_name"] = item['value'];
      }
    }
    String image_Str = '';
    int isupdate = 0;
    print(imgs);
    if (imgs.length < 5) {
      Toast.show('请至少上传五张图片', context);
      return;
    }
    for (var i = 0; i < imgs.length; i++) {
      var item = imgs[i];
      print(item);
      if (item['isupdate'] == 1) {
        isupdate++;
      }

      var tempStr = "";
      if (item.containsKey('attachment')) {
        tempStr = item['attachment'];
      }
      if (i == imgs.length - 1) {
        image_Str = image_Str + tempStr;
      } else
        image_Str = image_Str + tempStr + ',';
    }
    if (isupdate == 0) {
      //请上传图片
      Toast.show('请上传图片', context);
      return;
    }
    param["thumb"] = image_Str;
    // param["brand_id"] = formList[1]["brand_id"];
    // param["cartype_id"] = formList[2]['type_id'];
    // param["type_list_id"] = formList[3]['typelist_id'];
    // param["type_list_name"] = formList[3]['value'];
    if (thumb.length > 1) {
      param['thumb_img'] = thumb[1]['url'];
    }

    param['xsz'] = xsz_url;
    param["car_num"] = pwdData;
    // param["appoint_order_id"] = widget.appoint_order_id;
    // param["price"]=formList[1]["value"].toString();
    // param["contact_people"]=formList[2]["value"].toString();
    // param["contact_mobile"]=formList[3]["value"].toString();
    // param["address"]=formList[4]["value"].toString();
    // param["car_descrble"]=formList[6]["value"].toString();
    SharedPreferences pref = await SharedPreferences.getInstance();
    if (widget.type == 1) {
      param["appoint_order_id"] = widget.appoint_order_id;
      param['bid'] = widget.bid;
      param["is_bussiness_submit"] = "0";
    } else {
      param["bid"] = pref.getString('uid').toString();
      param["is_bussiness_submit"] = "1";
    }
    param['fdj'] = fdj;
    print(param);

    HttpHelper.post(HttpHelper.API_BussinessSuborder, (data) async {
      //loadpage.close();
      //loadpage.close();
      if (data != null) {
        print(data);
        //Toast.show(data["msg"], context);

        if (data["code"].toString() == "1") {
          SpUtil.remove('caches'); //清除车源信息缓存
          if (widget.type == 1) {
            // 检测师提交车源信息后跳转到检测订单
            Toast.show('提交成功，请继续检测', context);
            Navigator.of(context).pop(1);
            // Navigator.of(context).push(new MaterialPageRoute(builder: (_) {
            //   return new StartPicPage(widget.appoint_order_id, "认证检测");
            // })).then((param) {
            //   // loadOrderInfo();
            // });
          } else {
            // 车商提交信息后，需要生成定订单
            Toast.show('提交成功，请等待处理', context);
            Navigator.pop(context);
          }
          // if (pref.getString('agent').toString() == "0") {
          //   showAlert(data["info"].toString());
          // } else {
          //   Toast.show('车源提交成功，请等待审核', context);
          // }
          // _countdownTimer?.cancel();
          // _countdownTimer = null;
          // for (var i = 0; i < formList.length; i++) {
          //   //提交之后，把本地内容清空
          //   var item = formList[i];
          //   item['isedit'] = 0;
          // }
          // setState(() {
          //   formList = formList;
          // });
          // //Toast.show('请开始检测', context);
          // //清空输入框
          // car_num.clear();

          // address.clear();
          // car_price.clear();
          // desrible.clear();
          // people.clear();
          // mobile.clear();
          // for (int i = 0; i < formList.length; i++) {
          //   formList[i]["value"] = "";
          // }
          // setState(() {
          //   formList = formList;
          //   imgs = [];
          //   pwdData = "输入车牌";
          //   // img_url=[];
          // });

          // imgs.add('resource/images/user/upimg.png');

        } else {
          Toast.show(data['msg'], context);
        }
      }
    }, params: param);
  }

  showAlert(id) {
    showDialog<Null>(
      context: context,
      builder: (BuildContext context) {
        return new AlertDialog(
            title: Text('提示!'),
            content: new Text('您的车源已提交，若完成车况检测将会优先置顶展示'),
            actions: <Widget>[
              new FlatButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                    Navigator.of(context)
                        .push(new MaterialPageRoute(builder: (_) {
                      return new BussinessPapularinspects(id, 2, {});
                    }));
                    // Navigator.of(context)
                    //     .push(new MaterialPageRoute(builder: (_) {
                    //   return new Papularinspects(id, 2, {});
                    // }));
                    //connect();
                    // Navigator.pop(context);
                  },
                  child: new Text(
                    '确定',
                    style: new TextStyle(color: Colors.black),
                  ))
            ]);
      },
    );
  }

  //车架号输入组件
  Widget chejiainputWidget(item) {
    TextInputType texttype = TextInputType.text;
    if (item['text_type'] == 1) {
      texttype = TextInputType.number;
    } else if (item['text_type'] == 2) {
      texttype = TextInputType.text;
    }

    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
          color: Colors.white,
          height: 50,
          child: new Row(
            children: <Widget>[
              Expanded(
                child: new Padding(
                  padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                  child: RichText(
                    text: TextSpan(
                        text: item["title"],
                        style: TextStyle(fontSize: 15, color: Colours.text_gray
                            //color: Color.fromRGBO(102, 102, 102, 1)
                            ),
                        children: [
                          // TextSpan(
                          //     text: '*',
                          //     style: TextStyle(fontSize: 14, color: Colors.red))
                        ]),
                  ),
                ),
                flex: 1,
              ),
              Expanded(
                child: new Padding(
                    padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                    child: new TextField(
                      style: TextStyle(fontSize: 14),
                      textAlign: TextAlign.right,
                      controller: item["ctroller"],
                      maxLength: item["max_length"],
                      maxLengthEnforced: true,
                      inputFormatters: [
                        FilteringTextInputFormatter.allow(RegExp('[0-9A-Z]')),
                        FilteringTextInputFormatter.deny(RegExp('[IOQ]')),
                      ],

                      keyboardType: texttype,
                      //                  inputFormatters: <TextInputFormatter>[
                      //      LengthLimitingTextInputFormatter(20)//限制长度
                      //  ],

                      decoration: InputDecoration(
                        counterText: "",
                        hintText: '请输入' + item["title"],
                        border: OutlineInputBorder(
                          borderSide: BorderSide.none,
                        ),
                      ),
                      onChanged: (val) {
                        setState(() {
                          item['value'] = val;
                        });
                        saveResult(false);
                        // if (item['title'] == "车架号") {
                        //   if (val.contains('I') ||
                        //       val.contains('O') ||
                        //       val.contains('Q')) {
                        //     chejia.text = chejia.text
                        //         .substring(0, chejia.text.length - 1);
                        //     // print(chejiaController.text);
                        //   } else {
                        //     setState(() {
                        //       item["value"] = val;
                        //       item['isedit'] = 1;
                        //     });
                        //     // setState(() {
                        //     //   item['value'] = value;
                        //     // });
                        //     // saveResult();
                        //   }
                        //   setState(() {
                        //     item["value"] = chejia.text;
                        //     item['isedit'] = 1;
                        //   });
                        // } else {
                        //   setState(() {
                        //     item["value"] = val;
                        //     item['isedit'] = 1;
                        //   });
                        // }
                        // saveResult(false);
                      },
                    )),
                flex: 2,
              )
            ],
          ),
        ));
    return content;
    // Widget content = Padding(
    //     padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
    //     child: Container(
    //       color: Colors.white,
    //       height: 50,
    //       child: new Row(
    //         children: <Widget>[
    //           Expanded(
    //             child: new Padding(
    //               padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
    //               child: RichText(
    //                 text: TextSpan(
    //                     text: item["title"],
    //                     style: TextStyle(fontSize: 15, color: Colours.text_gray
    //                         //color: Color.fromRGBO(102, 102, 102, 1)
    //                         ),
    //                     children: [
    //                       // TextSpan(
    //                       //     text: '*',
    //                       //     style: TextStyle(fontSize: 14, color: Colors.red))
    //                     ]),
    //               ),
    //             ),
    //             flex: 1,
    //           ),
    //           Expanded(
    //               child: InkWell(
    //                   onTap: () {
    //                     showModalBottomSheet(
    //                         context: context,
    //                         builder: (BuildContext context) {
    //                           return ChejiaBoard((val){},item['value']);
    //                         });
    //                   },
    //                   child: Text(item['value'])))
    //         ],
    //       ),
    //     ));
    // return content;
  }

  //输入框组件
  Widget inputWidget(item) {
    TextInputType texttype = TextInputType.text;
    if (item['text_type'] == 1) {
      texttype = TextInputType.number;
    } else if (item['text_type'] == 2) {
      texttype = TextInputType.text;
    }

    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
          color: Colors.white,
          height: 50,
          child: new Row(
            children: <Widget>[
              Expanded(
                child: new Padding(
                  padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                  child: RichText(
                    text: TextSpan(
                        text: item["title"],
                        style: TextStyle(fontSize: 15, color: Colours.text_gray
                            //color: Color.fromRGBO(102, 102, 102, 1)
                            ),
                        children: [
                          // TextSpan(
                          //     text: '*',
                          //     style: TextStyle(fontSize: 14, color: Colors.red))
                        ]),
                  ),
                ),
                flex: 1,
              ),
              item["max_length"] > 0
                  ? Expanded(
                      child: new Padding(
                          padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                          child: new TextField(
                            style: TextStyle(fontSize: 14),
                            textAlign: TextAlign.right,
                            controller: item["ctroller"],
                            maxLength: item["max_length"],
                            maxLengthEnforced: true,

                            keyboardType: texttype,
                            //                  inputFormatters: <TextInputFormatter>[
                            //      LengthLimitingTextInputFormatter(20)//限制长度
                            //  ],

                            decoration: InputDecoration(
                              counterText: "",
                              hintText: '请输入' + item["title"],
                              border: OutlineInputBorder(
                                borderSide: BorderSide.none,
                              ),
                            ),
                            onChanged: (val) {
                              if (item['title'] == "车架号") {
                                if (val.contains('I') ||
                                    val.contains('O') ||
                                    val.contains('Q')) {
                                  chejia.text = chejia.text
                                      .substring(0, chejia.text.length - 1);
                                  // print(chejiaController.text);
                                } else {
                                  setState(() {
                                    item["value"] = val;
                                    item['isedit'] = 1;
                                  });
                                  // setState(() {
                                  //   item['value'] = value;
                                  // });
                                  // saveResult();
                                }
                                setState(() {
                                  item["value"] = chejia.text;
                                  item['isedit'] = 1;
                                });
                              } else {
                                setState(() {
                                  item["value"] = val;
                                  item['isedit'] = 1;
                                });
                              }
                              saveResult(false);
                            },
                          )),
                      flex: 2,
                    )
                  : Expanded(
                      child: new Padding(
                          padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                          child: new TextField(
                            style: TextStyle(fontSize: 14),
                            textAlign: TextAlign.right,
                            controller: item["ctroller"],

                            keyboardType: texttype,
                            //                  inputFormatters: <TextInputFormatter>[
                            //      LengthLimitingTextInputFormatter(20)//限制长度
                            //  ],

                            decoration: InputDecoration(
                              hintText: item['code'] == "price"
                                  ? item["value"]
                                  : '请输入' + item["title"],
                              border: OutlineInputBorder(
                                borderSide: BorderSide.none,
                              ),
                            ),
                            onChanged: (val) {
                              setState(() {
                                item["value"] = val;
                                item['isedit'] = 1;
                              });
                              saveResult(false);
                            },
                          )),
                      flex: 2,
                    )
            ],
          ),
        ));
    return content;
  }

  //日期选择组件
  Widget dateSelect(item) {
    DateTime initialDate = DateTime.now();
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
          color: Colors.white,
          height: 50,
          child: new Row(
            children: <Widget>[
              Expanded(
                child: new Padding(
                  padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                  child: RichText(
                    text: TextSpan(
                        text: item["title"],
                        style: TextStyle(
                            fontSize: 15,
                            color: Color.fromRGBO(102, 102, 102, 1)),
                        children: [
                          // TextSpan(
                          //     text: '*',
                          //     style: TextStyle(fontSize: 14, color: Colors.red))
                        ]),
                  ),
                ),
                flex: 1,
              ),
              Expanded(
                child: Padding(
                    padding: new EdgeInsets.fromLTRB(10, 0, 20, 0),
                    child: Align(
                        alignment: Alignment.centerRight,
                        child: new GestureDetector(
                            child: new Text(item["value"]),
                            onTap: () async {
                              _showDatePicker(item);
                              // final DateTime dateTime = await showDatePicker(
                              //   context: context,
                              //   //定义控件打开时默认选择日期
                              //   initialDate: initialDate,
                              //   //��义控件最早可以选择的日期
                              //   firstDate: DateTime(2018, 1),
                              //   //定义控件最晚可以选择的日期
                              //   lastDate: DateTime(2050, 1),
                              // );

                              // if (dateTime != null) {
                              //   setState(() {
                              //     String code = item["code"];
                              //     item["value"] = formatDate(
                              //         dateTime, [yyyy, "-", mm, "-", dd]);
                              //     //formalities[code] = item["value"];
                              //   });
                              // }
                            }))),
                flex: 2,
              )
            ],
          ),
        ));
    return content;
  }

  void _showDatePicker(item) {
    print('选择日期');
    DatePicker.showDatePicker(
      context,
      onMonthChangeStartWithFirstDate: true,
      pickerTheme: DateTimePickerTheme(
        showTitle: true,
        confirm: Text('确定', style: TextStyle(color: Colors.red)),
        cancel: Text('取消', style: TextStyle(color: Colors.cyan)),
      ),
      minDateTime: DateTime.parse(MIN_DATETIME),
      maxDateTime: DateTime.parse(MAX_DATETIME),
      initialDateTime: _dateTime,
      dateFormat: _format,
      locale: _locale,
      onClose: () => print("----- onClose -----"),
      onCancel: () => print('onCancel'),
      onChange: (dateTime, List<int> index) {
        print(dateTime);
        setState(() {
          _dateTime = dateTime;
        });
      },
      onConfirm: (dateTime, List<int> index) {
        print(dateTime);
        setState(() {
          //  String code = item["code"];
          item["value"] = formatDate(dateTime, [yyyy, "-", mm]);
          item["isedit"] = 1;
          //formalities[code] = item["value"];
        });
        setState(() {
          _dateTime = dateTime;
        });
        saveResult(false);
      },
    );
  }

  //车辆类型组件
  Widget cartype(item) {
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
            color: Colors.white,
            height: 50,
            child: new GestureDetector(
              behavior: HitTestBehavior.opaque,
              onTap: () {
                FocusScope.of(context).requestFocus(FocusNode());
                //print('选择车型');
                if (item.containsKey("brand_id")) {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (_) {
                    return new BrandSelectRoute(item);
                  })).then((param) {
                    if (current_brand != param['brand_id']) {
                      // this.formList[2]['value'] = '请选择车型';
                      // this.formList[2]['type_id'] = '';
                      // this.formList[1]['isedit'] = 1;
                      for (var brand in formList) {
                        if (brand['title'] == "车辆车系") {
                          brand['value'] = '请选择车系';
                          brand['type_id'] = '';
                        }
                        if (brand['title'] == "车辆品牌") {
                          brand['isedit'] = 1;
                        }
                      }
                      current_type = "";
                    }
                    setState(() {
                      current_brand = param['brand_id'];
                      formList = this.formList;
                    });
                    saveResult(false);
                  });
                } else if (item.containsKey("typelist_id")) {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (_) {
                    return new CartypeSelectRoute(
                        item, current_brand, current_type);
                    // return new CartypeSelectRoute(
                    //     item, formList[1]["brand_id"], formList[2]["type_id"]);
                  })).then((param) {
                    print('回传数据');
                    print(param);
                    if (param['price'] != "") {
                      // this.formList[3]['isedit'] = 1;
                      // this.formList[4]['value'] = param['price']
                      // .substring(0, param['price'].length - 1);
                      for (var brand in formList) {
                        if (brand['title'] == "新车指导价格") {
                          brand['value'] = param['price']
                              .substring(0, param['price'].length - 1);
                          // brand['type_id'] = '';
                        }
                        if (brand['title'] == "车辆车型") {
                          brand['isedit'] = 1;
                        }
                      }
                    }
                    // this.formList[4]['isedit'] = 1;
                    setState(() {
                      formList = this.formList;
                      guide_car_price.text = param['price']
                          .substring(0, param['price'].length - 1);
                    });
                    saveResult(false);
                  });
                } else {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (_) {
                    return new CartypeSelectRoute(item, current_brand, '0');
                  })).then((param) {
                    if (current_brand != param['type_id']) {
                      // this.formList[3]['value'] = '请选择款式';
                      // this.formList[3]['typelist_id'] = '';
                      for (var brand in formList) {
                        if (brand['title'] == "车辆车型") {
                          brand['value'] = '请选择款式';
                          brand['typelist_id'] = '';
                          // brand['type_id'] = '';
                        }
                      }
                      //current_type = "";
                    }
                    setState(() {
                      current_type = param['type_id'];
                      formList = this.formList;
                    });
                    saveResult(false);
                  });
                }
              },
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: <Widget>[
                  Expanded(
                    child: new Padding(
                      padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
                      child: RichText(
                        text: TextSpan(
                            text: item["title"],
                            style:
                                TextStyle(fontSize: 15, color: Colours.text_gray
                                    // color: Color.fromRGBO(102, 102, 102, 1)
                                    ),
                            children: [
                              // TextSpan(
                              //     text: '*',
                              //     style: TextStyle(fontSize: 14, color: Colors.red))
                            ]),
                      ),
                    ),
                  ),
                  //  Expanded(
                  //   child:
                  new Padding(
                    padding: new EdgeInsets.fromLTRB(10, 0, 0, 0),
                    child: RichText(
                      text: TextSpan(
                          text: item["value"],
                          style: TextStyle(
                              fontSize: 15,
                              color: Color.fromRGBO(102, 102, 102, 1)),
                          children: [
                            // TextSpan(
                            //     text: '*',
                            //     style: TextStyle(fontSize: 14, color: Colors.red))
                          ]),
                    ),
                  ),

                  //),
                  // Expanded(
                  //   child:
                  Padding(
                      padding: new EdgeInsets.fromLTRB(10, 0, 20, 0),
                      child: Align(
                          alignment: Alignment.centerRight,
                          child: Image.asset(
                            'resource/images/user/detail.png',
                            height: 20,
                          ))),

                  // )
                ],
              ),
            )));
    return content;
  }

  // //车辆类型组件
  // Widget cartype(item) {
  //   Widget content = Padding(
  //       padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
  //       child: Container(
  //           color: Colors.white,
  //           height: 50,
  //           child: new GestureDetector(
  //             behavior: HitTestBehavior.opaque,
  //             onTap: () {
  //               FocusScope.of(context).requestFocus(FocusNode());
  //               //print('选择车型');
  //               if (item.containsKey("brand_id")) {
  //                 Navigator.of(context)
  //                     .push(new MaterialPageRoute(builder: (_) {
  //                   return new BrandSelectRoute(item);
  //                 })).then((param) {
  //                   if (current_brand != param['brand_id']) {
  //                     this.formList[2]['value'] = '请选择车型';
  //                     this.formList[2]['type_id'] = '';
  //                     this.formList[1]['isedit'] = 1;
  //                     current_type = "";
  //                   }
  //                   setState(() {
  //                     current_brand = param['brand_id'];
  //                     formList = this.formList;
  //                   });
  //                   saveResult(false);
  //                 });
  //               } else if (item.containsKey("typelist_id")) {
  //                 Navigator.of(context)
  //                     .push(new MaterialPageRoute(builder: (_) {
  //                   return new CartypeSelectRoute(
  //                       item, formList[1]["brand_id"], formList[2]["type_id"]);
  //                 })).then((param) {
  //                   print('回传数据');
  //                   print(param);
  //                   if (param['price'] != "" &&
  //                       param['price'] != this.formList[4]['value']) {
  //                     this.formList[3]['isedit'] = 1;
  //                     this.formList[4]['value'] = param['price']
  //                         .substring(0, param['price'].length - 1);
  //                   }
  //                   this.formList[4]['isedit'] = 1;
  //                   setState(() {
  //                     formList = this.formList;
  //                     guide_car_price.text = param['price']
  //                         .substring(0, param['price'].length - 1);
  //                   });
  //                   saveResult(false);
  //                 });
  //               } else {
  //                 Navigator.of(context)
  //                     .push(new MaterialPageRoute(builder: (_) {
  //                   return new CartypeSelectRoute(
  //                       item, formList[1]["brand_id"], '0');
  //                 })).then((param) {
  //                   if (current_brand != param['type_id']) {
  //                     this.formList[3]['value'] = '请选择款式';
  //                     this.formList[3]['typelist_id'] = '';
  //                     //current_type = "";
  //                   }
  //                   setState(() {
  //                     current_type = param['type_id'];
  //                     formList = this.formList;
  //                   });
  //                   saveResult(false);
  //                 });
  //               }
  //             },
  //             child: new Row(
  //               mainAxisAlignment: MainAxisAlignment.end,
  //               children: <Widget>[
  //                 Expanded(
  //                   child: new Padding(
  //                     padding: new EdgeInsets.fromLTRB(10, 0, 10, 0),
  //                     child: RichText(
  //                       text: TextSpan(
  //                           text: item["title"],
  //                           style:
  //                               TextStyle(fontSize: 15, color: Colours.text_gray
  //                                   // color: Color.fromRGBO(102, 102, 102, 1)
  //                                   ),
  //                           children: [
  //                             // TextSpan(
  //                             //     text: '*',
  //                             //     style: TextStyle(fontSize: 14, color: Colors.red))
  //                           ]),
  //                     ),
  //                   ),
  //                 ),
  //                 //  Expanded(
  //                 //   child:
  //                 new Padding(
  //                   padding: new EdgeInsets.fromLTRB(10, 0, 0, 0),
  //                   child: RichText(
  //                     text: TextSpan(
  //                         text: item["value"],
  //                         style: TextStyle(
  //                             fontSize: 15,
  //                             color: Color.fromRGBO(102, 102, 102, 1)),
  //                         children: [
  //                           // TextSpan(
  //                           //     text: '*',
  //                           //     style: TextStyle(fontSize: 14, color: Colors.red))
  //                         ]),
  //                   ),
  //                 ),

  //                 //),
  //                 // Expanded(
  //                 //   child:
  //                 Padding(
  //                     padding: new EdgeInsets.fromLTRB(10, 0, 20, 0),
  //                     child: Align(
  //                         alignment: Alignment.centerRight,
  //                         child: Image.asset(
  //                           'resource/images/user/detail.png',
  //                           height: 20,
  //                         ))),

  //                 // )
  //               ],
  //             ),
  //           )));
  //   return content;
  // }

  //新版图片上传
  Widget uploadImgs(item) {
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
          color: Colors.white,
          width: double.infinity,
          // height: 160,
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              new Padding(
                padding: new EdgeInsets.fromLTRB(10, 10, 10, 0),
                child: RichText(
                  text: TextSpan(
                      text: item["title"],
                      style: TextStyle(
                          fontSize: 15,
                          color: Color.fromRGBO(102, 102, 102, 1)),
                      children: [
                        // TextSpan(
                        //     text: '*',
                        //     style: TextStyle(fontSize: 14, color: Colors.red))
                      ]),
                ),
              ),
              Padding(
                  padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                  child: Container(
                      color: Colors.white,
                      // height: 100,
                      child: new Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            new Container(
                                child: buildCImgs(
                                    item["title"] == "车源封面图片" ? thumb : imgs))
                          ]))),

              //  Expanded(
              //   child:
            ],
          ),
        ));
    return content;
  }

  // //图片上传组件
  // Widget imagUp(item) {
  //   Widget content = Padding(
  //       padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
  //       child: Container(
  //         color: Colors.white,
  //         width: double.infinity,
  //         // height: 160,
  //         child: new Column(
  //           mainAxisAlignment: MainAxisAlignment.start,
  //           crossAxisAlignment: CrossAxisAlignment.start,
  //           children: <Widget>[
  //             new Padding(
  //               padding: new EdgeInsets.fromLTRB(10, 10, 10, 0),
  //               child: RichText(
  //                 text: TextSpan(
  //                     text: item["title"],
  //                     style: TextStyle(
  //                         fontSize: 15,
  //                         color: Color.fromRGBO(102, 102, 102, 1)),
  //                     children: [
  //                       // TextSpan(
  //                       //     text: '*',
  //                       //     style: TextStyle(fontSize: 14, color: Colors.red))
  //                     ]),
  //               ),
  //             ),
  //             Padding(
  //                 padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
  //                 child: Container(
  //                     color: Colors.white,
  //                     // height: 100,
  //                     child: new Column(
  //                         mainAxisAlignment: MainAxisAlignment.start,
  //                         crossAxisAlignment: CrossAxisAlignment.start,
  //                         children: <Widget>[
  //                           new Container(child: buildCImgs())
  //                         ]))),

  //             //  Expanded(
  //             //   child:
  //           ],
  //         ),
  //       ));
  //   return content;
  // }

  Widget textarea(item) {
    Widget content = Padding(
        padding: new EdgeInsets.fromLTRB(0, 0, 0, item["bottom"]),
        child: Container(
          color: Colors.white,
          width: double.infinity,

          // height: 160,
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              new Padding(
                padding: new EdgeInsets.fromLTRB(10, 10, 10, 0),
                child: RichText(
                  text: TextSpan(
                      text: item["title"],
                      style: TextStyle(
                          fontSize: 15,
                          color: Color.fromRGBO(102, 102, 102, 1)),
                      children: [
                        // TextSpan(
                        //     text: '*',
                        //     style: TextStyle(fontSize: 14, color: Colors.red))
                      ]),
                ),
              ),
              Padding(
                  padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                  child: Container(
                      color: Colors.white,
                      // height: 100,
                      child: new Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            new Container(
                                child: new TextFormField(
                              style: TextStyle(fontSize: 14),
                              maxLines: 10,
                              textAlign: TextAlign.left,
                              controller: item["ctroller"],
                              decoration: InputDecoration(
                                hintText: '请输入' + item["title"],
                                border: OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                              ),
                              onChanged: (val) {
                                setState(() {
                                  item["value"] = val;
                                });

                                saveResult(false);
                              },
                            ))
                          ]))),

              //  Expanded(
              //   child:
            ],
          ),
        ));
    return content;
  }

  List imageModelinspectitem(data) {
    List img_temp = [
      "https://car3.autoimg.cn/cardfs/product/g1/M09/3F/A8/240x180_0_q95_c42_autohomecar__ChwFqV69W4KAf_AzAAShphUBgV4514.jpg",
      "https://car2.autoimg.cn/cardfs/product/g25/M09/6E/D2/240x180_0_q95_c42_autohomecar__ChwFj169W32Ad5ehAAT2abQFAio994.jpg",
      "https://car2.autoimg.cn/cardfs/product/g25/M08/6E/D2/240x180_0_q95_c42_autohomecar__ChwFj169W3uATe71AASA9ZdptWg816.jpg",
      "https://car2.autoimg.cn/cardfs/product/g25/M0B/73/06/240x180_0_q95_c42_autohomecar__ChsEmF69W3qAYeneAAQeve0abAo167.jpg",
    ];
    List imgList = List();
    for (int x = 0; x < data.length; x++) {
      GalleryExampleItem item = GalleryExampleItem();
      item.id = '$x';
      item.resource = data[x]['url'];
      // item.resource = data[x]["url"];
      imgList.add(item);
    }
    print(imgList.first.id);

    return imgList;
  }

  Widget buildCImgs(data) {
    List<Widget> tiles = [];

    Widget content;

    List items = data;
    print(items);
    // print('图片数组长度'+items.isNotEmpty.toString());
    if (items.length > 0) {
      // tiles.add(new Container(
      //       padding: new EdgeInsets.fromLTRB(60, 0, 20, 0),)
      for (var i = 0; i < items.length; i++) {
        //List temp1 = items[i] as List;
        tiles.add(new Container(
            width: 120,
            height: 130,
            padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
            child: Padding(
                padding: new EdgeInsets.fromLTRB(5, 10, 0, 10),
                child: GestureDetector(
                    onTap: () {
                      if (i == 0) {
                        FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
                        print('点击查看图片');
                        if (data == thumb && thumb.length == 2) {}
                        getImage(data == imgs ? 0 : 1);
                      } else {
                        //查看图片
                        Navigator.of(context).push(new FadeRoute(
                            page: GalleryPhotoViewWrapper(
                          galleryItems: imageModelinspectitem(data),
                          backgroundDecoration: const BoxDecoration(
                            color: Colors.black,
                          ),
                          initialIndex: i,
                        )));
                      }
                    },
                    child: new Column(
                      children: <Widget>[
                        items[i]['isupdate'] == 0
                            ? Image.asset('resource/images/user/upimg.png',
                                width: 100, height: 100)
                            : Stack(children: [
                                Positioned(
                                    //  top:5,
                                    //  bottom: 0,
                                    //  left:0,
                                    //  right: 0,
                                    child: CachedNetworkImage(
                                  imageUrl: items[i]['url'],
                                  width: 100,
                                  height: 100,
                                  fit: BoxFit.cover,
                                )),
                                Positioned(
                                  right: -10,
                                  top: -10,
                                  child: IconButton(
                                      onPressed: () {
                                        deleteimg(i, data);
                                        // if (data == imgs) {
                                        //   imgs.removeAt(i);
                                        //   setState(() {
                                        //     imgs = imgs;
                                        //   });
                                        // } else {
                                        //   thumb.removeAt(i);
                                        //   setState(() {
                                        //     thumb = thumb;
                                        //   });
                                        // }
                                      },
                                      icon: Icon(Icons.delete,
                                          color: Colors.red)),
                                )
                              ]),
                        // : CachedNetworkImage(
                        //     imageUrl: items[i]['url'],
                        //     width: 100,
                        //     height: 100,
                        //   ),
                        //Image.network(items[i]['url'], width: 100, height: 100),
                        // Center(child: Text(items[i]['name']))
                      ],
                    )))));
      }
    }
    content = new Wrap(
        children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
        //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
        );
    return content;
  }
  // Widget buildCImgs() {
  //   List<Widget> tiles = [];

  //   Widget content;

  //   List items = imgs;
  //   print(items);
  //   // print('图片数组长度'+items.isNotEmpty.toString());
  //   if (items.length > 0) {
  //     // tiles.add(new Container(
  //     //       padding: new EdgeInsets.fromLTRB(60, 0, 20, 0),)
  //     for (var i = 0; i < items.length; i++) {
  //       //List temp1 = items[i] as List;
  //       tiles.add(new Container(
  //           width: 120,
  //           height: 160,
  //           padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
  //           child: Padding(
  //               padding: new EdgeInsets.fromLTRB(5, 10, 0, 10),
  //               child: GestureDetector(
  //                   onTap: () {
  //                     FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
  //                     print('点击查看图片');
  //                     getImage(i);
  //                     // if (i == items.length - 1) {
  //                     //   getImage();
  //                     // }
  //                     // Navigator.of(context).push(
  //                     //   NinePicture(items, i),
  //                     //);
  //                   },
  //                   child: new Column(
  //                     children: <Widget>[
  //                       items[i]['isupdate'] == 0
  //                           ? Image.asset('resource/images/user/upimg.png',
  //                               width: 100, height: 100)
  //                           : CachedNetworkImage(
  //                               imageUrl: items[i]['url'],
  //                               width: 100,
  //                               height: 100,
  //                             ),
  //                       //Image.network(items[i]['url'], width: 100, height: 100),
  //                       Center(child: Text(items[i]['name']))
  //                     ],
  //                   )))));
  //     }
  //   }
  //   content = new Wrap(
  //       children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
  //       //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
  //       );
  //   return content;
  // }
//   //选择图片
//   getimgs(type, card) async {
//     if (type == 1) {
//       var image = await ImagePicker.pickImage(source: ImageSource.gallery);

//       setState(() {
//         _image = image;
//         select_img = true;
//       });
//     } else {
//       var image = await ImagePicker.pickImage(source: ImageSource.camera);

//       setState(() {
//         _image = image;
//         select_img = true;
//       });
//     }
//     if (_image == null) return;
//     Map<String, String> map = new Map();

//     HttpHelper.upLoadImage(_image, (data) {
//       if (card == 1) {
//         setState(() {
//           card_z = data["url"];
//         });
//       } else {
//         card_f = data["url"];
//       }
//     }, params: map);
//   }

// //选择图片�����
//   Future getImage(type) async {
//     showDialog(
//         context: context,
//         builder: (BuildContext context) {
//           return new SimpleDialog(
//             title: new Text('选择'),
//             children: <Widget>[
//               new SimpleDialogOption(
//                 child: new Text('相机'),
//                 onPressed: () {
//                   Navigator.pop(context);
//                   getimgs(0, type);
//                 },
//               ),
//               new SimpleDialogOption(
//                 child: new Text('相册'),
//                 onPressed: () {
//                   Navigator.pop(context);
//                   getimgs(1, type);
//                 },
//               )
//             ],
//           );
//         });
//     // var image = await ImagePicker.pickImage(source: ImageSource.gallery);
//     // //_upLoadImage(image);//上传图片
//     // setState(() {
//     //   _image = image;
//     // });
//   }

  deleteimg(index, data) {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return Padding(
              padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
              child: Container(
                height: 130,
                child: new Column(children: <Widget>[
                  new Container(
                      decoration: new BoxDecoration(
                          border: Border(
                              bottom: BorderSide(
                                  width: 1, color: Color(0xffe5e5e5)))),
                      height: 50,
                      child: Center(
                          child: Text('是否删除此图片！',
                              style: TextStyle(fontSize: 16)))),
                  new Container(
                      decoration: new BoxDecoration(
                          border: Border(
                              bottom: BorderSide(
                                  width: 1, color: Color(0xffe5e5e5)))),
                      height: 40,
                      child: new GestureDetector(
                          behavior: HitTestBehavior.opaque,
                          onTap: () async {
                            Navigator.pop(context);
                            //删除图片

                            if (data == imgs) {
                              if (imgs.length > 0) {
                                imgs.removeAt(index);
                                setState(() {
                                  imgs = imgs;
                                });
                              }
                            } else {
                              if (thumb.length > 0) {
                                thumb.removeAt(index);
                                setState(() {
                                  thumb = thumb;
                                });
                              }
                            }
                          },
                          child: Center(
                              child: Text('确认删除',
                                  style: TextStyle(
                                      fontSize: 16, color: Colors.red))))),
                  new Container(
                      height: 40,
                      child: new GestureDetector(
                          behavior: HitTestBehavior.opaque,
                          onTap: () {
                            Navigator.pop(context);
                          },
                          child: Center(
                              child:
                                  Text('取消', style: TextStyle(fontSize: 16))))),
                ]),
              ));
        });
  }

//选择图片
  getimgs(type, index) async {
    var image;
    if (type == 1) {
      image = await ImagePicker.pickImage(source: ImageSource.gallery);
    } else {
      image = await ImagePicker.pickImage(source: ImageSource.camera);
    }
    if (image == null) return;
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    // File _files = await FlutterNativeImage.compressImage(image.path);
    File _files = image;

    Map<String, String> map = new Map();
    Map imgitem;
    HttpHelper.upLoadImageNocompress(_files, (data) {
      //loadpage.close();
      print('data');
      if (data.containsKey('code')) {
        Toast.show(data['msg'], context);
      } else {
        // imgs.removeLast();
        // imgs.add(data["url"]);
        // imgs[index]['isupdate'] = 1;
        // imgs[index]['url'] = data["url"];
        // imgs[index]['attachment'] = data["attachment"];
        // // img_url[index]=(data["attachment"]);
        // //imgs.add('resource/images/user/upimg.png');
        // setState(() {
        //   imgs = imgs;
        // });
        imgitem = {
          'isupdate': 1,
          'url': data["url"],
          'attachment': data["attachment"]
        };
        if (index == 0)
          imgs.add(imgitem);
        else {
          if (thumb.length > 1) {
            thumb.removeLast();
          }
          thumb.add(imgitem);
        }

        // img_url[index]=(data["attachment"]);
        //imgs.add('resource/images/user/upimg.png');
        setState(() {
          imgs = imgs;
          thumb = thumb;
        });

        saveResult(false);
        _saveImg(data["url"]);
      }
    }, params: map);

    // if (_image == null) return;
    // Map<String, String> map = new Map();
    // HttpHelper.upLoadImage(_image, (data) {
    //   if(data.containsKey('code')){
    //     Toast.show(data['msg'], context);
    //   }else{
    //   setState(() {
    //     avatar = data['url'];
    //   });
    //   uploadAvatar();
    //   }
    // }, params: map);
  }

//选择图片方式
  Future getImage(i) async {
    showDialog(
        context: context,
        builder: (BuildContext context) {
          return new SimpleDialog(
            title: new Text('选择'),
            children: <Widget>[
              new SimpleDialogOption(
                child: new Text('相机'),
                onPressed: () {
                  Navigator.pop(context);
                  getimgs(0, i);
                },
              ),
              new SimpleDialogOption(
                child: new Text('相册'),
                onPressed: () async {
                  Navigator.pop(context);
                  List<AssetEntity> temp = await AssetPicker.pickAssets(context,
                      maxAssets: i == 0 ? 9 : 1);
                  if (temp != null) {
                    for (var item in temp) {
                      File file = await item.file;
                      print(file.path);
                      Map<String, String> map = new Map();
                      Map imgitem;
                      HttpHelper.upLoadImageNocompress(File(file.path), (data) {
                        // print('data');
                        if (data.containsKey('code')) {
                          Toast.show(data['msg'], context);
                        } else {
                          imgitem = {
                            'isupdate': 1,
                            'url': data["url"],
                            'attachment': data["attachment"]
                          };
                          if (i == 0)
                            imgs.add(imgitem);
                          else {
                            if (thumb.length > 1) {
                              thumb.removeLast();
                            }
                            thumb.add(imgitem);
                          }

                          setState(() {
                            imgs = imgs;
                            thumb = thumb;
                          });

                          saveResult(false);
                        }
                      }, params: map);
                    }
                  }
                },
              )
            ],
          );
        });
    // var image = await ImagePicker.pickImage(source: ImageSource.gallery);
    // //_upLoadImage(image);//上传图片
    // setState(() {
    //   _image = image;
    // });
  }

  @override
  void dispose() {
    // _countdownTimer?.cancel();
    // _countdownTimer = null;
    super.dispose();
    print('销毁');
  }

  Widget build(BuildContext context) {
    //认证检测时先要上传车源信息
    super.build(context);
    return new Scaffold(
      key: _scaffoldKey,
      appBar: new AppBar(
        titleSpacing: 0,
        title: new Text(
          titleshow,
          style: TextStyle(fontSize: Config.title_size),
        ),
        backgroundColor: Colors.white,
        elevation: 0,
        // backgroundColor: Color.fromRGBO(255, 204, 48, 1),
      ),
      // floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
      // floatingActionButton: FloatingActionButton(
      //   onPressed: () {
      //    saveResult(true);
      //   },
      //   child: Icon(
      //     Icons.save,
      //     color: Colors.white,
      //   ),
      //    backgroundColor: Colours.bj_orange_o2,
      //   // backgroundColor: Color.fromRGBO(27, 182, 251, 1),
      // ),
      body: status == "1"
          ? new Center(
              child: Container(
                  decoration: new BoxDecoration(
                      //color:Colours.base_page_color,
                      // color: Color.fromRGBO(238, 238, 238, 1),
                      ),
                  child: Padding(
                      padding: new EdgeInsets.fromLTRB(0, 15, 0, 0),
                      child: Stack(
                        children: <Widget>[
                          Padding(
                              padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                              child: Align(
                                  alignment: Alignment.topLeft,
                                  child: ispay == false
                                      ? GestureDetector(
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (_) {
                                              return new BevipPage();
                                            })).then((param) {
                                              loaduserinfo();
                                            });
                                            // Navigator.of(context).push(
                                            //     new MaterialPageRoute(
                                            //         builder: (_) {
                                            //   return new BevipPage();
                                            // }));
                                          },
                                          child: new Container(
                                              color: Colors.red,
                                              width: double.infinity,
                                              padding: new EdgeInsets.fromLTRB(
                                                  10, 10, 0, 10),
                                              child:
                                                  // Align(
                                                  //   alignment: Alignment.center,
                                                  //   child:
                                                  new Text(
                                                      isend == true
                                                          ? '您的免费试用时间已过期！点击充值成为正式会员'
                                                          : '您的免费试用还有' +
                                                              days +
                                                              '天结束！点击充值成为正式会员',
                                                      style: TextStyle(
                                                          color: Colors.white,
                                                          fontSize: 13))))
                                      : new Container(height: 0))),
                          Padding(
                              padding: new EdgeInsets.fromLTRB(
                                  0, ispay == true ? 0 : 40, 0, 0),
                              child: Align(
                                alignment: Alignment.topCenter,
                                child:
                                    new ListView(children: <Widget>[layout()]),
                              )),
                          Align()
                        ],
                      )
                      // new ListView(
                      //   children: <Widget>[buildcontent()],
                      // )),
                      )))
          : new Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[Text('您的账号正在审核，请耐心等待！')],
              ),
            ),
    );
  }
}
